# Maintainer: Ryuta Suzuki <oroppas@gmail.com>

_realname=path.py
pkgbase=mingw-w64-python3-path
pkgname=("${MINGW_PACKAGE_PREFIX}-python3-path")
pkgver=12.0.2
pkgrel=1
pkgdesc="File system based database that uses python pickles (mingw-w64)"
url="https://pypi.org/project/path.py/"
arch=('any')
license=('MIT')
depends=("${MINGW_PACKAGE_PREFIX}-python3"
         "${MINGW_PACKAGE_PREFIX}-python3-importlib-metadata")
makedepends=("${MINGW_PACKAGE_PREFIX}-python3-setuptools"
             "${MINGW_PACKAGE_PREFIX}-python3-setuptools-scm")
checkdepends=("${MINGW_PACKAGE_PREFIX}-python3-pytest-runner"
              "${MINGW_PACKAGE_PREFIX}-python3-pytest-flake8")
source=("${_realname}-${pkgver}.tar.gz"::"https://github.com/jaraco/path.py/archive/v${pkgver}.tar.gz")
sha512sums=('8eb0f3046e8c642356dca9c51e3670475680d641d4d4252cfada48a2b179dbe22d05fa6c15782cd7913e30cb8d522cc681c47cf50e13fe8095f18f047bbf68ac')

prepare() {
  rm -rf python3-build-${CARCH}
  cp -r "${_realname}-${pkgver}" "python3-build-${CARCH}"
  # Set version for setuptools_scm
  export SETUPTOOLS_SCM_PRETEND_VERSION=${pkgver}
}

build() {
  cd "${srcdir}/python3-build-${CARCH}"
  ${MINGW_PREFIX}/bin/python3 setup.py build
}

check() {
  cd "${srcdir}/python3-build-${CARCH}"
  ${MINGW_PREFIX}/bin/python3 setup.py pytest || true
}

package() {
  cd "${srcdir}/python3-build-${CARCH}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
    ${MINGW_PREFIX}/bin/python3 setup.py install --root=${pkgdir} --prefix=${MINGW_PREFIX} --optimize=1 --skip-build
  install -Dm644 LICENSE ${pkgdir}${MINGW_PREFIX}/share/licenses/python3-${_realname}/LICENSE
}
